from pythonds.basic.stack import Stack


def tenTo(decNumber,base):
    digits = "0123456789ABCDEF"
    remstatck = Stack()
    while decNumber > 0:
        rem = decNumber % base  # 取余得出转化后的值  变为索引值了
        remstatck.push(rem)
        decNumber = decNumber // base # 整除得出下一次需要除的数
    newString = ''
    while not remstatck.isEmpty():
        newString += digits[remstatck.pop()]
    return newString


print(tenTo(25,16)) # 19
print(tenTo(25,2)) # 11001
print(tenTo(1000,16)) # 3E8
print(tenTo(58,8)) # 72
print(tenTo(58,6)) # 134
